auto merge of #369 : alexcrichton/cargo/issue-327, r=wycats
authorbors <bors@rust-lang.org>
Fri, 15 Aug 2014 04:28:57 +0000 (04:28 +0000)
committerbors <bors@rust-lang.org>
Fri, 15 Aug 2014 04:28:57 +0000 (04:28 +0000)
The syntax was originally chosen to perhaps allow multiple libraries in the future, but that is less and less likely to happen at this point. This commit deprecates the now-misleading `[[lib]]` in favor of `[lib]` to indicate that only one can be present.

This does not start allowing `[bin]` or `[example]` and such as I felt that it was too many ways to specify what's essentially the same thing. This also as a bonus allows a top-level `bin = []` to completely opt-out of binary inference (as well as for tests and examples).

Closes #327

1  2 
src/cargo/core/manifest.rs
src/cargo/util/toml.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_test.rs

Simple merge
index 0cbea63eb817f21e35380c1cb765d0643ed261fd,d39b613f87e0e73b5de724f25e926195f0c2729c..a5bf74c49f27e5c78e68a78459b93463e8f7f6c3
@@@ -314,56 -312,55 +330,61 @@@ impl TomlManifest 
          // If we have a lib with a path, we're done
          // If we have a lib with no path, use the inferred lib or_else package name
  
-         let lib = if self.lib.is_none() || self.lib.get_ref().is_empty() {
-             inferred_lib_target(project.name.as_slice(), layout)
-         } else {
-             self.lib.get_ref().iter().map(|t| {
-                 if layout.lib.is_some() && t.path.is_none() {
-                     TomlTarget {
-                         path: layout.lib.as_ref().map(|p| TomlPath(p.clone())),
-                         .. t.clone()
-                     }
-                 } else {
-                     t.clone()
+         let mut used_deprecated_lib = false;
+         let lib = match self.lib {
+             Some(ref libs) => {
+                 match *libs {
+                     Many(..) => used_deprecated_lib = true,
+                     _ => {}
                  }
-             }).collect()
+                 libs.as_slice().iter().map(|t| {
+                     if layout.lib.is_some() && t.path.is_none() {
+                         TomlTarget {
+                             path: layout.lib.as_ref().map(|p| TomlPath(p.clone())),
+                             .. t.clone()
+                         }
+                     } else {
+                         t.clone()
+                     }
+                 }).collect()
+             }
+             None => inferred_lib_target(project.name.as_slice(), layout),
          };
  
-         let bins = if self.bin.is_none() || self.bin.get_ref().is_empty() {
-             inferred_bin_targets(project.name.as_slice(), layout)
-         } else {
-             let bin = layout.main();
+         let bins = match self.bin {
+             Some(ref bins) => {
+                 let bin = layout.main();
  
-             self.bin.get_ref().iter().map(|t| {
-                 if bin.is_some() && t.path.is_none() {
-                     TomlTarget {
-                         path: bin.as_ref().map(|&p| TomlPath(p.clone())),
-                         .. t.clone()
+                 bins.iter().map(|t| {
+                     if bin.is_some() && t.path.is_none() {
+                         TomlTarget {
+                             path: bin.as_ref().map(|&p| TomlPath(p.clone())),
+                             .. t.clone()
+                         }
+                     } else {
+                         t.clone()
                      }
-                 } else {
-                     t.clone()
-                 }
-             }).collect()
+                 }).collect()
+             }
+             None => inferred_bin_targets(project.name.as_slice(), layout)
          };
  
-         let examples = if self.example.is_none() || self.example.get_ref().is_empty() {
-             inferred_example_targets(layout)
-         } else {
-             self.example.get_ref().iter().map(|t| t.clone()).collect()
+         let examples = match self.example {
+             Some(ref examples) => examples.clone(),
+             None => inferred_example_targets(layout),
          };
  
-         let tests = if self.test.is_none() || self.test.get_ref().is_empty() {
-             inferred_test_targets(layout)
-         } else {
-             self.test.get_ref().iter().map(|t| t.clone()).collect()
+         let tests = match self.test {
+             Some(ref tests) => tests.clone(),
+             None => inferred_test_targets(layout),
          };
  
 +        let benches = if self.bench.is_none() || self.bench.get_ref().is_empty() {
 +            inferred_bench_targets(layout)
 +        } else {
 +            self.bench.get_ref().iter().map(|t| t.clone()).collect()
 +        };
 +
          // Get targets
          let targets = normalize(lib.as_slice(),
                                  bins.as_slice(),
Simple merge
Simple merge